<?php
require('config.php');
		$getGrage=3;
		if(isset($_REQUEST['getGrage'])) $getGrage=$_REQUEST['getGrage'];
		$sql="select * from `".$oto."_goods_cats` where catFlag=1 and isFixed=0 and isShow=1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$list[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$yiji_num=0;
		for($i=0;$i<count($list);$i++)
		{
			if($list[$i]['parentId']==0)
			{
				$data[$yiji_num]=$list[$i];
				$erji_num=0;
				if((int)$getGrage>1)
				{
					for($j=0;$j<count($list);$j++)
					{
						if($list[$i]['catId']==$list[$j]['parentId'])
						{
							$data[$yiji_num]['list'][$erji_num]=$list[$j];
							$sanji_num=0;
							if((int)$getGrage>2)
							{
								for($k=0;$k<count($list);$k++)
								{
									if($list[$j]['catId']==$list[$k]['parentId'])
									{
										$data[$yiji_num]['list'][$erji_num]['list'][$sanji_num]=$list[$k];
										$sanji_num++;
									}
								}
								if($sanji_num==0) $data[$yiji_num]['list'][$erji_num]['list']=[];
							}
							$erji_num++;
						}
					}
					if($erji_num==0) $data[$yiji_num]['list']=[];
				}
				$yiji_num++;
			}
		}
		//print_r($data);
		echo json_encode($data);
?>